#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["L.M.System.Read.API/L.M.System.Read.API.csproj", "L.M.System.Read.API/"]
COPY ["A.M.RabbitMQ/A.M.RabbitMQ.csproj", "A.M.RabbitMQ/"]
COPY ["AliInfor_Verification_code/AliInfor_Verification_code.csproj", "AliInfor_Verification_code/"]
COPY ["Attribute_Extension/Attribute_Extension.csproj", "Attribute_Extension/"]
COPY ["ConsulUIlity/ConsulUIlity.csproj", "ConsulUIlity/"]
COPY ["L.M.System.Application/L.M.System.Application.csproj", "L.M.System.Application/"]
COPY ["A.M.Storage.Application/A.M.Storages.Services.csproj", "A.M.Storage.Application/"]
COPY ["A.M.Storage.I_Application/A.M.Storages.IServices.csproj", "A.M.Storage.I_Application/"]
COPY ["A.M.ETO/A.M.ETO.csproj", "A.M.ETO/"]
COPY ["A.M.Storage.I_Infrastruecure/A.M.Storages.IRepository.csproj", "A.M.Storage.I_Infrastruecure/"]
COPY ["L.M.System.Domain/L.M.System.Domain.csproj", "L.M.System.Domain/"]
COPY ["L.M.System.Infrastruecure/L.M.System.Infrastruecure.csproj", "L.M.System.Infrastruecure/"]
COPY ["A.M.Storage.Infrastruecure/A.M.Storage.Repository.csproj", "A.M.Storage.Infrastruecure/"]
COPY ["Redis_ClientInfor/Redis_ClientInfor.csproj", "Redis_ClientInfor/"]
COPY ["L.M.System.ErrorCodeEnum/L.M.System.ErrorCodeEnum.csproj", "L.M.System.ErrorCodeEnum/"]
COPY ["Linked_Database/Linked_Database.csproj", "Linked_Database/"]
COPY ["Public_Class_Library/Public_Class_Library.csproj", "Public_Class_Library/"]
RUN dotnet restore "./L.M.System.Read.API/L.M.System.Read.API.csproj"
COPY . .
WORKDIR "/src/L.M.System.Read.API"
RUN dotnet build "./L.M.System.Read.API.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./L.M.System.Read.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "L.M.System.Read.API.dll"]